package com.qf.lanzhou.shop.admin.service.impl;

import com.qf.lanzhou.shop.admin.dao.SellerMapper;
import com.qf.lanzhou.shop.admin.service.SellerService;

import com.qf.lanzhou.shop.pojo.entity.Seller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author jack
 */
@Service
public class SellerServiceImpl implements SellerService {

    @Autowired
    private SellerMapper sellerMapper;

    @Override
    public Seller getSeller(String name) {
        Seller seller = sellerMapper.selectByName(name);
        System.out.println("service" + seller);
        if (seller == null) {
            return null;
        }
        return seller;
    }

    @Override
    public int upload(String name, String avatar) {
        Seller seller = new Seller();
        seller.setSellerName(name);
        seller.setAvatarAddress(avatar);
        int i = sellerMapper.updateByNameWithLicense(seller);
        return i;
    }

    @Override
    public boolean addSeller(Seller seller) {
        int i = sellerMapper.inserSeller(seller);
        if (i == 1) {
            return false;
        }
        return true;
    }

    @Override
    public String getAvatar(String name) {
        String s = sellerMapper.selectAratarByName(name);
        return s;
    }

    @Override
    public Seller getSellerById(Long id) {
        Seller seller = sellerMapper.selectById(id);
        return seller;
    }


}
